#include<iostream>
#include<vector>
using namespace std;
const int N = 1e6 + 10;
vector<int> edges[N];
bool st[N];
void dfs(int u)
{
	cout << u << ' ';
	st[u] = true;
	for (auto v : edges[u])
	{
		if (st[v] == false) dfs(v);
	}
}
int main()
{
	int u;cin >> u;
	for (int i = 1; i <= u; i++)
	{
		int a, b;cin >> a >> b;
		edges[a].push_back(b);
		edges[b].push_back(a);
	}
	dfs(u);
	return 0;
}